From 7ecdaaacb2d8a4454ef44517adb296b31746d99f Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 29 Nov 2014 01:55:06 +0100 Subject: [PATCH] widget: Clarify some corner cases I checked Cairo source code (actually pixman, as Cairo just passes through) to make sure that the behavior stays identical: negative values cause an error message from pixman, zero is allowed. Both return an empty region which gtk_widget_queue_draw_region() would then proceed to ignore. --- gtk/gtkwidget.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 7ff1aff3f0..0be0272070 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5657,6 +5657,9 @@ gtk_widget_queue_draw_region (GtkWidget *widget, * defined as @widget->window coordinates for widgets that are not * #GTK_NO_WINDOW widgets, and are relative to @widget->allocation.x, * @widget->allocation.y for widgets that are #GTK_NO_WINDOW widgets. + * + * @width or @height may be 0, in this case this function does + * nothing. Negative values for @width and @height are not allowed. */ void gtk_widget_queue_draw_area (GtkWidget *widget, @@ -5669,6 +5672,11 @@ gtk_widget_queue_draw_area (GtkWidget *widget, cairo_region_t *region; g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (width >= 0); + g_return_if_fail (height >= 0); + + if (width == 0 || height == 0) + return; rect.x = x; rect.y = y; -- 2.30.2